package com.chinasofti.testbigdecimal;

import java.math.BigDecimal;

public class MyBigDecimal2 {
    public static void main(String[] args) {
        //精确运算
        BigDecimal bd1 = new BigDecimal("0.2");
        //System.out.println("bd1 = " + bd1);
        BigDecimal bd2 = new BigDecimal("0.1");
        //System.out.println("bd2 = " + bd2);

        //加法
        BigDecimal add = bd1.add(bd2);
        System.out.println("add = " + add);


        //减法
        BigDecimal subtract = bd1.subtract(bd2);
        System.out.println("subtract = " + subtract);


        //乘法
        BigDecimal multiply = bd1.multiply(bd2);
        System.out.println("multiply = " + multiply);

        //除法
        BigDecimal divide = bd1.divide(bd2);
        System.out.println("divide = " + divide);

        System.out.println(10.0/3.0);
    }
}
